/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.gob.pnp.servlets;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.Logger;
/**
 *
 * @author Ecampos
 */
public class LiquidacionServlet extends HttpServlet{

    private static final Logger logger = Logger.getLogger(LiquidacionServlet.class);
    
    protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String nliqu_codigo = request.getParameter("nliqu_codigo");
        response.setContentType("application/pdf");
        ServletOutputStream out = response.getOutputStream();
        try {
            
            PDFLiquidacion pdf = new PDFLiquidacion();
            pdf.crearPdfLiquidacion(out, nliqu_codigo);

        } catch (Exception ex){
            ex.printStackTrace();
            throw new ServletException(ex);
        }finally {
            out.close();
        }

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
